#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("nuclear.in" , "r" , stdin);
	freopen("nuclear.out" , "w" , stdout);
	int n , m;
	cin >> n >> m;
	long long f[55];
	f[0] = 1;
	for(int i = 1 ; i <= n ; i++){
		if(i == m){
			f[i] = 1 << i;
			f[i]--;
		}
		else if(i < m){
			f[i] = 1 << i;
		}
		else{
			f[i] = 2 * f[i - 1] - f[i - m - 1];
		}
	}
	cout << f[n] << endl;
	return 0;
}
